home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc1_2_x / stabilzr.sit / The Stabilizer / stack.txt < prev   
Text File  |  1989-02-05  |  29KB  |  799 lines

  1. -- stack: in
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 6
  11. -- first background id: 2175
  12. -- card count: 34
  13. -- first card id: 9877
  14. -- list block id: 18180
  15. -- print block id: 13286
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 127296 bytes
  21. -- stack block size: 23552 bytes
  22. -- created by hypercard version: 0x00000000
  23. -- compacted by hypercard version: 0x01208000
  24. -- modified by hypercard version: 0x01208000
  25. -- opened by hypercard version: 0x01208000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. --Copyright ┬⌐1988 - Scott McGilliard - all rights reserved
  69. --Thank you to: Andrew Gilmartin (Brown University) for XFCN PopUpMenu
  70.  
  71. on openStack
  72.   global saveMsg
  73.   hide msg
  74.   hide menuBar
  75.   put loc of msg into saveMsg
  76.   push card "Expenses"
  77.   get card field "allExpenses" of card "whichMonths"
  78.   if it = empty then exit openStack
  79.   get the date
  80.   convert it to seconds
  81.   if it >= line 2 of card field "startMonth" of card "Year Totals" then
  82.     answer "It's time to recalculate, do it now?" with "No" or "Yes"
  83.     if it is "Yes" then
  84.       put last word of the long date into whichYear
  85.       if word 1 of item 2 of the long date Γëá "January" then put " -" && whichYear + 1 after whichYear
  86.       set loc of msg to 19,106
  87.       put "Estimating expenses for" && whichYear & ", please wait."
  88.       get line 2 of card field "startMonth" of card "Year Totals"
  89.       convert it to long date
  90.       add 1 to last item of it
  91.       convert it to seconds
  92.       put it into line 2 of card field "startMonth" of card "Year Totals"
  93.       doEstimate
  94.       doMath
  95.       hide msg
  96.     end if
  97.   end if
  98. end openStack
  99.  
  100. on idle
  101.   global moreExpenses
  102.   if moreExpenses = 1 then addExpense
  103.   set cursor to 5
  104.   pass idle
  105. end idle
  106.  
  107. on helpIndex
  108.   visual venetian blinds to gray
  109.   visual venetian blinds
  110.   go card "HelpIndex"
  111. end helpIndex
  112.  
  113. on addExpense
  114.   global expenseAmount,expense,moreExpenses
  115.   push card
  116.   Get card field "allExpenses" of card "whichMonths"
  117.   if the number of lines of it >= 48 then
  118.     answer "You can not enter more than 48 items" with "OK"
  119.     get field expense3 of card "Expenses"
  120.     if line 16 of it = empty then noMore
  121.     put empty into moreExpenses
  122.     exit addExpense
  123.   end if
  124.   set numberFormat to "0.00"
  125.   repeat forever
  126.     ask "Please enter an expense item"
  127.     repeat
  128.       if "," is in it then
  129.         put offset (",",it) into er
  130.         delete char er of it
  131.       else
  132.         exit repeat
  133.       end if
  134.     end repeat
  135.     put it into expenseItem
  136.     if expenseItem = empty then exit repeat
  137.     if the length of expenseItem > 18 then
  138.       answer "Expense items can have only 18 characters" with "OK"
  139.       exit addExpense
  140.     end if
  141.     put expenseItem&"," into expense
  142.     answer "Do you pay the same amount every time?" with "No" or "Yes"
  143.     if it is "yes" then
  144.       repeat forever
  145.         ask "Please enter the amount for"&&expenseItem
  146.         if it is empty then
  147.           answer "Do you want to delete this expense?" with "Yes" or "No"
  148.           if it is "yes" then
  149.             put empty into expense
  150.             exit repeat
  151.           else
  152.             next repeat
  153.           end if
  154.         else
  155.           exit repeat
  156.         end if
  157.       end repeat
  158.       if expense = empty then next repeat
  159.       put "$" into expenseAmount
  160.       if char 1 of it = "$" then delete char 1 of it
  161.       repeat
  162.         if "," is in it then
  163.           put offset (",",it) into er
  164.           delete char er of it
  165.         else
  166.           exit repeat
  167.         end if
  168.       end repeat
  169.       add 0 to it
  170.       put it & "," after expenseAmount
  171.       put expenseAmount after expense
  172.       answer "Do you pay this expense every month?" with "No" or "Yes"
  173.     else
  174.       put "variable," into expenseAmount
  175.       put expenseAmount after expense
  176.     end if
  177.     if it is "yes" and expenseAmount Γëá "variable," then
  178.       put "Every┬áMonth" after expense
  179.       exit repeat
  180.     else
  181.       visual venetian blinds to gray
  182.       visual venetian blinds
  183.       go card "whichMonths"
  184.       put empty into moreExpenses
  185.       exit addExpense
  186.     end if
  187.   end repeat
  188.   doAlphabet
  189.   answer "Are you finished adding expenses?" with "Yes" or "No"
  190.   if it = "yes" then
  191.     put the number of lines of card field "allExpenses" of card "whichMonths" into test1
  192.     put the number of lines of field "expense" of card "Expenses" into test2
  193.     add the number of lines of field "expense2" of card "Expenses" to test2
  194.     add the number of lines of field "expense3" of card "Expenses" to test2
  195.     if test2 < test1 then
  196.       noMore
  197.     else
  198.       put empty into moreExpenses
  199.     end if
  200.   end if
  201. end addExpense
  202.  
  203. on doAlphabet
  204.   global expense
  205.   set cursor to 4
  206.   set loc of msg to 19,106
  207.   put "Please wait"
  208.   if expense = empty then
  209.     hide msg
  210.     exit doAlphabet
  211.   end if
  212.   repeat with x = 1 to the length of item 1 of expense
  213.     put the charToNum of char x of item 1 of expense into temp
  214.     if temp >= 97 and temp <= 122 then
  215.       put temp - 32 into temp
  216.       put the numToChar of temp into char x of item 1 of expense
  217.     end if
  218.   end repeat
  219.   put card field "allExpenses" of card "whichMonths" into allExpenses
  220.   if allExpenses = empty then
  221.     put expense into card field "allExpenses" of card "whichMonths"
  222.     put empty into expense
  223.     hide msg
  224.     exit doAlphabet
  225.   end if
  226.   put item 1 of expense into ex
  227.   put 1 into y
  228.   put 1 into z
  229.   repeat
  230.     if ex = item 1 of line y of allExpenses then
  231.       answer "You can't enter the same expense item twice." with "OK"
  232.       ask "Please enter a different name for" && ex
  233.       if it = ex or it = empty then
  234.         put empty into expense
  235.         hide msg
  236.         exit doAlphabet
  237.       else
  238.         repeat
  239.           if "," is in it then
  240.             put offset (",",it) into er
  241.             delete char er of it
  242.           else
  243.             exit repeat
  244.           end if
  245.         end repeat
  246.         put it into ex
  247.         repeat
  248.           if the length of ex > 18 then
  249.             delete last char of ex
  250.           else
  251.             exit repeat
  252.           end if
  253.         end repeat
  254.         repeat with x = 1 to the length of ex
  255.           put the charToNum of char x of ex into temp
  256.           if temp >= 97 and temp <= 122 then
  257.             put temp - 32 into temp
  258.             put the numToChar of temp into char x of ex
  259.           end if
  260.         end repeat
  261.         put ex into item 1 of expense
  262.         put 1 into y
  263.         put 1 into z
  264.       end if
  265.     end if
  266.     if line y of allExpenses = empty then
  267.       put return & expense after last line of card field "allExpenses" of card "whichMonths"
  268.       put empty into expense
  269.       hide msg
  270.       exit doAlphabet
  271.     end if
  272.     if the charToNum of char z of ex = the charToNum of char z of item 1 of line y of allExpenses then
  273.       add 1 to z
  274.       if char z of item 1 of line y of allExpenses = empty then
  275.         add 1 to y
  276.         put 1 into z
  277.         next repeat
  278.       end if
  279.       if char z of ex = empty then
  280.         put expense & return before line y of card field "allExpenses" of card "whichMonths"
  281.         put empty into expense
  282.         hide msg
  283.         exit doAlphabet
  284.       end if
  285.       next repeat
  286.     end if
  287.     if the charToNum of char z of ex < the charToNum of char z of item 1 of line y of allExpenses then
  288.       put expense & return before line y of card field "allExpenses" of card "whichMonths"
  289.       put empty into expense
  290.       hide msg
  291.       exit doAlphabet
  292.     else
  293.       add 1 to y
  294.       put "1" into z
  295.       next repeat
  296.     end if
  297.   end repeat
  298.   hide msg
  299. end doAlphabet
  300.  
  301. on noMore
  302.   global moreExpenses
  303.   set loc of msg to 19,106
  304.   put "This will take a couple of minutes, please wait."
  305.   put empty into moreExpenses
  306.   set cursor to 4
  307.   set lockScreen to true
  308.   put card field "allExpenses" of card "whichMonths" into allExpenses
  309.   repeat with x = 2 to 13
  310.     put empty into field expense of card x
  311.     put empty into field amount of card x
  312.     put empty into field expense2 of card x
  313.     put empty into field amount2 of card x
  314.   end repeat
  315.   put empty into field expense of card "Expenses"
  316.   put empty into field expense2 of card "Expenses"
  317.   put empty into field expense3 of card "Expenses"
  318.   repeat with i = 1 to the number of lines in allExpenses
  319.     put item 1 of line i of allExpenses into expenseName
  320.     put expenseName & return after field expense of card "Expenses"
  321.     if item 3 of line i of allExpenses = "Every Month" then
  322.       repeat with x = 2 to 13
  323.         put expenseName & return after field expense of card x
  324.         put item 2 of line i of allExpenses & return after field amount of card x
  325.       end repeat
  326.     else
  327.       if item 2 of line i of allExpenses = "Variable" then
  328.         repeat with x = 3 to the number of items in line i of allExpenses
  329.           put word 1 of item x of line i of allExpenses into which
  330.           put expenseName & return after field expense of card which
  331.           put last word of item x of line i of allExpenses & return after field amount of card which
  332.         end repeat
  333.       else
  334.         repeat with x = 3 to the number of items in line i of allExpenses
  335.           put item x of line i of allExpenses into which
  336.           put expenseName & return after field expense of card which
  337.           put item 2 of line i of allExpenses & return after field amount of card which
  338.         end repeat
  339.       end if
  340.     end if
  341.   end repeat
  342.   repeat with x = 2 to 13
  343.     put line 16 to 30 of field expense of card x into field expense2 of card x
  344.     delete line 16 to 30 of field expense of card x
  345.     put line 16 to 30 of field amount of card x into field amount2 of card x
  346.     delete line 16 to 30 of field amount of card x
  347.   end repeat
  348.   put line 17 to 32 of field expense of card "Expenses" into field expense2 of card "Expenses"
  349.   put line 33 to 48 of field expense of card "Expenses" into field expense3 of card "Expenses"
  350.   delete line 17 to 48 of field expense of card "Expenses"
  351.   hide msg
  352. end noMore
  353.  
  354. on seeItems
  355.   put card field "allExpenses" of card "whichMonths" into allExpenses
  356.   put (item 2 of the clickLoc - 39) div 16 into whichLine
  357.   put the short name of the target into whichField
  358.   if line whichLine of field whichField is empty then exit seeItems
  359.   get line whichLine of field whichField
  360.   repeat with i = 1 to the number of lines in allExpenses
  361.     if it = item 1 of line i of allExpenses then
  362.       put line i of allExpenses into theList
  363.       exit repeat
  364.     end if
  365.   end repeat
  366.   if item 3 of theList = "Every Month" then put "," & card field "monthList" of card "Expenses" after theList
  367.   put the mouseloc into listHere
  368.   put item 1 of listHere + 1 into horiz
  369.   put item 2 of listHere - 10 into vert
  370.   get the number of items in theList
  371.   put vert + (it * 17) into length
  372.   if length > 314 then subtract (length - 324) from vert
  373.   get PopUpMenu(theList, 1, vert, horiz)
  374.   put item it of theList into whatCard
  375.   if it = 1 then
  376.     visual barn door close slowly to gray
  377.     visual barn door open slowly
  378.     go card whatCard
  379.     if the result Γëá empty then
  380.       repeat
  381.         answer "Automatic cost adjustment for this expense?" with "Help" or "Yes" or "No"
  382.         if it = "Help" then
  383.           push card
  384.           visual venetian blinds
  385.           go card it
  386.           show card field "Cost"
  387.           repeat until the mouse is down
  388.           end repeat
  389.           visual venetian blinds
  390.           pop card
  391.         else
  392.           exit repeat
  393.         end if
  394.       end repeat
  395.       if it = "Yes" then
  396.         go card "template"
  397.         doMenu "New Card"
  398.         put item 1 of theList into bill
  399.         set name of this card to bill
  400.         put "," & bill after line 3 of card field "startMonth" of card "Year Totals"
  401.         repeat with y = 1 to the number of fields
  402.           put field y of card "template" into field y of card bill
  403.         end repeat
  404.         put bill into field "title" of card bill
  405.         put field "months" of card bill into tempMon
  406.         set numberFormat to "0.00"
  407.         if item 3 of theList = "Every Month" then
  408.           set numberFormat to "0"
  409.           ask "Enter amount for"&& bill && "in" && last item of the long date - 1 with item 2 of theList
  410.           set numberFormat to "0.00"
  411.           repeat
  412.             if "," is in it then
  413.               put offset (",",it) into er
  414.               delete char er of it
  415.             else
  416.               exit repeat
  417.             end if
  418.           end repeat
  419.           if it = empty then put item 2 of the list into it
  420.           if char 1 of it = "$" then delete char 1 of it
  421.           add 0 to it
  422.           put "$" before it
  423.           repeat with y = 1 to 12
  424.             put item 2 of theList into line y of act
  425.             put it into line y of amo
  426.           end repeat
  427.         else
  428.           if item 2 of theList = "variable" then
  429.             put theList into oldList
  430.             repeat with i = 3 to the number of items in theList
  431.               ask "Enter amount for 1 yr before last" && word 1 of item i of theList with last word of item i of theList
  432.               repeat
  433.                 if "," is in it then
  434.                   put offset (",",it) into er
  435.                   delete char er of it
  436.                 else
  437.                   exit repeat
  438.                 end if
  439.               end repeat
  440.               if it = empty then put last word of item i of theList into it
  441.               if char 1 of it = "$" then delete char 1 of it
  442.               add 0 to it
  443.               put "$" before it
  444.               repeat with x = 1 to 12
  445.                 if word 1 of item i of theList = line x of tempMon then exit repeat
  446.               end repeat
  447.               put last word of item i of theList into line x of act
  448.               put it into line x of amo
  449.             end repeat
  450.           else
  451.             put theList into oldList
  452.             set numberFormat to "0"
  453.             ask "Enter amount for"&& bill && "in" && last item of the long date - 1 with item 2 of theList
  454.             repeat
  455.               if "," is in it then
  456.                 put offset (",",it) into er
  457.                 delete char er of it
  458.               else
  459.                 exit repeat
  460.               end if
  461.             end repeat
  462.             set numberFormat to "0.00"
  463.             if it = empty then put item 2 of the list into it
  464.             if char 1 of it = "$" then delete char 1 of it
  465.             add 0 to it
  466.             put "$" before it
  467.             repeat with i = 3 to the number of items in theList
  468.               repeat with x = 1 to 12
  469.                 if word 1 of item i of theList = line x of tempMon then exit repeat
  470.               end repeat
  471.               put item 2 of theList into line x of act
  472.               put it into line x of amo
  473.             end repeat
  474.           end if
  475.           set cursor to 4
  476.         end if
  477.         put act into field "actual" of card bill
  478.         put amo into field "amount" of card bill
  479.         put "0" into totalAct
  480.         put "0" into totalAmo
  481.         repeat with y = 1 to 12
  482.           delete char 1 of line y of act
  483.           delete char 1 of line y of amo
  484.           add line y of act to totalAct
  485.           add line y of amo to totalAmo
  486.         end repeat
  487.         set numberFormat to "0.0"
  488.         put ((totalAct - totalAmo)/totalAmo)*100 into inc
  489.         if inc < 0 then put 0 into inc
  490.         put inc & "%" into line 2 of field "increase" of card bill
  491.         set numberFormat to "0.00"
  492.         repeat with y = 1 to 12
  493.           if line y of act Γëá empty then
  494.             put "$" & line y of amo + (line y of amo * inc/100) into line y of pro
  495.             put "$" & line y of amo - (line y of amo * inc/100) into line y of bas
  496.           end if
  497.         end repeat
  498.         put pro into field "projected" of card bill
  499.         put bas into field "base" of card bill
  500.         if item 2 of theList = "Variable" then
  501.           get word 1 of item 2 of the long date
  502.           repeat with i = 1 to 12
  503.             if it = line i of tempMon then exit repeat
  504.           end repeat
  505.           put i into t
  506.           repeat with i = i to 12
  507.             put line i of field "actual" of card bill into line i of field "amount" of card bill
  508.             put line i of field "amount" of card bill into line i of field "base" of card bill
  509.             if line i of act Γëá empty then
  510.               put "$" & line i of act + (line i of act * inc/100) into line i of field "projected" of card bill
  511.               put "$" & line i of act - (line i of act * inc/100) into line i of field "base" of card bill
  512.             end if
  513.             put empty into line i of field "actual" of card bill
  514.           end repeat
  515.           repeat
  516.             answer "Estimate" && bill && "and recalculate?" with "Help" or "Yes" or "No"
  517.             if it = "Help" then
  518.               push card
  519.               visual venetian blinds
  520.               go card it
  521.               show card field "Estimate"
  522.               repeat until the mouse is down
  523.               end repeat
  524.               visual venetian blinds
  525.               pop card
  526.             else
  527.               exit repeat
  528.             end if
  529.           end repeat
  530.           if it is "Yes" then
  531.             set loc of msg to 19,106
  532.             put "Estimating expense, please wait."
  533.             repeat with t = t to 12
  534.               get line t of field "amount" of card bill
  535.               if it Γëá empty then
  536.                 put line t of field "projected" of card bill into proAm
  537.                 put proAm into line t of field "actual" of card bill
  538.                 put line t of tempMon into whichMonth
  539.                 repeat with s = 1 to the number of items in theList
  540.                   if whichMonth is in item s of theList then exit repeat
  541.                 end repeat
  542.                 put proAm into last word of item s of theList
  543.                 repeat with y = 1 to 3
  544.                   if bill is in field y of card whichMonth then
  545.                     repeat with i = 1 to the number of lines in field y of card whichMonth
  546.                       if bill = line i of field y of card whichMonth then
  547.                         put proAm into line i of field (y + 1) of card whichMonth
  548.                         exit repeat
  549.                       end if
  550.                     end repeat
  551.                     exit repeat
  552.                   end if
  553.                 end repeat
  554.                 repeat with i = 1 to the number of lines in allExpenses
  555.                   if bill = item 1 of line i of allExpenses then
  556.                     put theList into line i of card field "allExpenses" of card "whichMonths"
  557.                     exit repeat
  558.                   end if
  559.                 end repeat
  560.               end if
  561.             end repeat
  562.             doMath
  563.           end if
  564.         end if
  565.       end if
  566.     end if
  567.   else
  568.     if whatCard = "Every Month" then
  569.       answer "You can't go to every month at once." with "OK"
  570.       exit seeItems
  571.     else
  572.       put word 1 of whatCard into whatCard
  573.     end if
  574.     visual barn door close slowly to gray
  575.     visual barn door open slowly
  576.     go card whatCard
  577.   end if
  578. end seeItems
  579.  
  580. on doEstimate
  581.   set cursor to 4
  582.   put last word of the long date into whichYear
  583.   if word 1 of item 2 of the long date Γëá "January" then put " -" && whichYear + 1 after whichYear
  584.   put whichYear into field "thisYear1" of card "template"
  585.   put whichYear into field "thisYear2" of card "template"
  586.   put "SUMMARY FOR" && whichYear into card field "title" of card "Year Totals"
  587.   if whichYear = last word of the long date then
  588.     put whichYear - 1 into field "lastYear" of card "template"
  589.   else
  590.     subtract 1 from first word of whichYear
  591.     subtract 1 from last word of whichYear
  592.     put whichYear into field "lastYear" of card "template"
  593.   end if
  594.   put card field "allExpenses" of card "whichMonths" into allExpenses
  595.   put line 3 of card field "startMonth" of card "Year Totals" into whichBill
  596.   put field "months" of card "template" into tempMon
  597.   repeat with i = 2 to the number of items in whichBill
  598.     put item i of whichBill into bill
  599.     repeat with x = 1 to the number of lines in allExpenses
  600.       if bill = item 1 of line x of allExpenses then
  601.         put line x of allExpenses into theList
  602.         exit repeat
  603.       end if
  604.     end repeat
  605.     put field "thisYear1" of card "template" into field "thisYear1" of card bill
  606.     put field "thisYear2" of card "template" into field "thisYear2" of card bill
  607.     put field "lastYear" of card "template" into field "lastYear" of card bill
  608.     put field "amount" of card bill into amo
  609.     put field "actual" of card bill into act
  610.     put field "projected" of card bill into pro
  611.     repeat with y = 1 to 12
  612.       if line y of amo Γëá empty and line y of act = empty then put line y of pro into line y of act
  613.     end repeat
  614.     if item 2 of theList Γëá "Variable" then
  615.       repeat with y = 1 to 12
  616.         if line y of act Γëá empty then
  617.           put line y of act into test
  618.           exit repeat
  619.         end if
  620.       end repeat
  621.       repeat with y = 1 to 12
  622.         if line y of act Γëá empty and line y of act Γëá test then exit repeat
  623.       end repeat
  624.       repeat with z = y to 12
  625.         if line z of amo Γëá empty then put test into line z of amo
  626.       end repeat
  627.       put amo into field "base" of card bill
  628.       put act into field "amount" of card bill
  629.       repeat with z = 1 to y - 1
  630.         if line z of act Γëá empty then
  631.           put line y of act into line z of act
  632.           put line y of act into line z of field "projected" of card bill
  633.         end if
  634.       end repeat
  635.       put line y of act into test2
  636.       delete char 1 of test
  637.       delete char 1 of test2
  638.       set numberFormat to "0.0"
  639.       put ((test2 - test)/test)*100 into inc
  640.       if inc < 0 then put 0 into inc
  641.       put inc & "%" into line 2 of field "increase" of card bill
  642.       set numberFormat to "0.00"
  643.       repeat with z = y to 12
  644.         if line z of amo Γëá empty then
  645.           delete char 1 of line z of act
  646.           put "$" & line z of act + (line z of act * inc/100) into line z of field "projected" of card bill
  647.           put "$" & line z of act + (line z of act * inc/100) into item 2 of theList
  648.         end if
  649.         put empty into line z of act
  650.       end repeat
  651.       put act into field "actual" of card bill
  652.     else
  653.       put amo into field "base" of card bill
  654.       put act into field "amount" of card bill
  655.       put empty into field "actual" of card bill
  656.       put "0" into totalAct
  657.       put "0" into totalAmo
  658.       repeat with y = 1 to 12
  659.         delete char 1 of line y of act
  660.         delete char 1 of line y of amo
  661.         add line y of act to totalAct
  662.         add line y of amo to totalAmo
  663.       end repeat
  664.       set numberFormat to "0.0"
  665.       put ((totalAct - totalAmo)/totalAmo)*100 into inc
  666.       if inc < 0 then put 0 into inc
  667.       put inc & "%" into line 2 of field "increase" of card bill
  668.       set numberFormat to "0.00"
  669.       repeat with y = 1 to 12
  670.         if line y of amo Γëá empty then put "$" & line y of act + (line y of act * inc/100) into line y of field "projected" of card bill
  671.       end repeat
  672.     end if
  673.     repeat with t = 1 to 12
  674.       get line t of field "projected" of card bill
  675.       if it Γëá empty then
  676.         put it into proAm
  677.         put line t of tempMon into whichMonth
  678.         if item 2 of theList = "variable" then
  679.           repeat with s = 1 to the number of items in theList
  680.             if whichMonth is in item s of theList then exit repeat
  681.           end repeat
  682.           put proAm into last word of item s of theList
  683.         end if
  684.         repeat with y = 1 to 3
  685.           if bill is in field y of card whichMonth then
  686.             repeat with i = 1 to the number of lines in field y of card whichMonth
  687.               if bill = line i of field y of card whichMonth then
  688.                 put proAm into line i of field (y + 1) of card whichMonth
  689.                 exit repeat
  690.               end if
  691.             end repeat
  692.             exit repeat
  693.           end if
  694.         end repeat
  695.         repeat with i = 1 to the number of lines in allExpenses
  696.           if bill = item 1 of line i of allExpenses then
  697.             put theList into line i of card field "allExpenses" of card "whichMonths"
  698.             exit repeat
  699.           end if
  700.         end repeat
  701.       end if
  702.     end repeat
  703.   end repeat
  704. end doEstimate
  705.  
  706. on doMath
  707.   set cursor to 4
  708.   set loc of msg to 19,106
  709.   put "Calculating, please wait."
  710.   set numberFormat to "0.00"
  711.   put "0" into temp4
  712.   repeat with x = 2 to 13
  713.     put "0" into temp2
  714.     repeat with i = 1 to the number of lines in field 2 of card x
  715.       put line i of field 2 of card x into temp1
  716.       delete char 1 of temp1
  717.       add temp1 to temp2
  718.     end repeat
  719.     repeat with i = 1 to the number of lines in field 4 of card x
  720.       put line i of field 4 of card x into temp1
  721.       delete char 1 of temp1
  722.       add temp1 to temp2
  723.     end repeat
  724.     put "$" & temp2 into field "subTotal" of card x
  725.     put "$" & temp2 & return after temp3
  726.     put temp2 & return after tempAm
  727.     add temp2 to temp4
  728.   end repeat
  729.   put temp3 into card field "amounts" of card "Year Totals"
  730.   put "$" & temp4 into card field "Total" of card "Year Totals"
  731.   put temp4 into deposit
  732.   divide deposit by 12
  733.   put "$" & deposit into card field "deposit/month" of card "Year Totals"
  734.   get word 1 of card field "pays" of card "Year Totals"
  735.   put temp4 into eachPay
  736.   divide eachPay by it
  737.   put "$" & eachPay into card field "perPay" of card "Year Totals"
  738.   put "0" into tempDep
  739.   get line 1 of card field "startMonth" of card "Year Totals"
  740.   if it = empty then
  741.     put "January" into line 1 of card field "startMonth" of card "Year Totals"
  742.     put "template" into line 3 of card field "startMonth" of card "Year Totals"
  743.     put card field "months" of card "Year Totals" into field "months" of card "template"
  744.     put "January" && "1," & last item of the long date into startDate
  745.     convert startDate to dateItems
  746.     get the date
  747.     convert it to dateItems
  748.     set numberFormat to "0"
  749.     if item 2 of it >= item 2 of startDate then add 1 to item 1 of startDate
  750.     convert startDate to date
  751.     convert startDate to seconds
  752.     put startDate into line 2 of card field "startMonth" of card "Year Totals"
  753.     put "January" into it
  754.   end if
  755.   repeat with i = 1 to 12
  756.     if it = line i of card field "months" of card "Year Totals" then exit repeat
  757.   end repeat
  758.   set numberFormat to "0.00"
  759.   repeat 12
  760.     add deposit to tempDep
  761.     put tempDep - line i of tempAm into line i of tempBal
  762.     put line i of tempBal into tempDep
  763.     if i = 12 then put 1 into i
  764.     else add 1 to i
  765.   end repeat
  766.   repeat with i = 1 to 12
  767.     put "$" before char 1 of line i of tempBal
  768.   end repeat
  769.   put tempBal into card field "balance" of card "Year Totals"
  770.   hide msg
  771. end doMath
  772.  
  773. on closeStack
  774.   global saveMsg
  775.  
  776.   if the diskSpace >= size of this stack then
  777.  
  778.     get the freeSize of stack
  779.     if it > 1024 * 10 then
  780.       put trunc(it/1024) + 1 into extra
  781.       answer extra & "K of free space...compact stack?" with "Cancel" or "Compact"
  782.       if it = "Compact" then
  783.         if the userLevel < 4 then
  784.           put the userLevel into saveLevel
  785.           set the userLevel to 5
  786.           doMenu "Compact Stack"
  787.           set the userLevel to saveLevel
  788.         else
  789.           doMenu "Compact Stack"
  790.         end if
  791.       end if
  792.     end if
  793.   end if
  794.   set loc of msg to saveMsg
  795.   show menuBar
  796. end closeStack
  797.  
  798.  
  799.